
function a(e) {
  console.log('a e', e)
  var a = e.type;
  return "notice" === a ? notice(e) : "multitype" === a ? t(e) : "goods" === a ? i(e) : "page" === a ? goPage(e) : "shop" ===a ? l(e) : void 0;
}

function e(e) {
  console.log('golink e', e)
  var t = a(e);
  console.log('e t',t)
  if (t) {
    var i = e.saOption, n = e.saOption, d = n.componentName, o = n.floorIndex, r = n.positionIndex, g = getApp();
    var p = {
      cType: i.componentName,
      cIndex: i.floorIndex,
      cId: Number(i.timestamp),
      cTop: i.offsetTop,
      sIndex: i.positionIndex + 1,
      t: s.formatTime(new Date())
    }, 
    l = JSON.parse(g.getStorageSync("channelOrigin") || "{}"), 
    c = void 0;
    console.log('g.getCPages()', g.getCPages().route)
    var page = g.getCPages().route.indexOf("pages/home/");
    var small = g.getCPages().route.indexOf("pages/smallPage/");
    var detail = t.indexOf("pages/productdetail/")
    page > -1 ? (p.pageId = "index", c = "index") : small > -1 && (p.pageId = g.getCPages().options.id, c = "smallPage"),      detail > -1 && (l.referPageData = p, g.setStorageSync("sendType", "smallPage")),
    "index" != c && "smallPage" != c || 
    (l.startPageData ? l.endPageData && "index" == l.endPageData.pageId ? "index" == c && (l.endPageData = p) : l.endPageData = p : l.startPageData = p,g.setStorageSync("channelOrigin", JSON.stringify(l))), 
      getApp().goUrl(t);
  }
}

function l(e) {
  console.log('店铺定位等 e', e)
  var item = e.data.item
  var latitude = item.latitude
  var longitude = item.longitude
  // wx.openLocation({
  //   latitude,
  //   longitude,
  //   scale: 17
  // })
  var url = ''
  url = '/pages/shop/detail/index?id=' + item.id
  return url;
}

function notice(e) {
  console.log('通知公告 e',e)
  var a = e.data, t = a.type, i = a.item.linkKey, n = "", s = (e.saOption || {}).componentName,k = a.item.id;
  console.log('t ',t)
  if ("notice" == t) { n = '/pages/notice/detail/index?id=' + i }///文章
  else {
    if ("MINIPROGRAM_LINK" !== t) return "";
    n = i;
  }
  return s && (n += "&sa_unit=" + s), n;
}
function t(e) {
  console.log('砍价等 e',e)
  var a = e.data, t = a.type, i = a.item.linkId, n = "", s = (e.saOption || {}).componentName,k = a.item.id;
  console.log('t ',t)
  if ("article" == t) { n = '/pages/article/index?id=' + i }///文章
  else if ("page" === t) { n = "/pages/smallPage/index?id=" + i; } //商品页
  else if ("product" === t) { n = "/pages/product/detail/index?id=" + i;} //商品详情
  else if ("link" === t) n = i; 
  else {
    if ("MINIPROGRAM_LINK" !== t) return "";
    n = i;
  }
  return s && (n += "&sa_unit=" + s), n;
}
//商品
function i(e) {
  console.log('商品 e', e)
  var linkType = e.data.item.linkType
  console.log('linkType',linkType)
  var a = e.data.item,n=""
  console.log('a',a)
  if (linkType == 'group'){//团购的 商品详情
    var i = a.groupbuy.id
    var c = a.groupbuy.linkType// 1 - 商品  2 - 优惠券
    var linkId = a.groupbuy.linkId
    n = "/pages/product/detail/index?id=" + linkId + "&group_id=" + i +"&groupopenId=0"
  } else if (linkType == 'product') {//普通商品的 商品详情
    var linkId = a.product.id
    n = "/pages/product/detail/index?id=" + linkId + "&group_id=0&groupopenId=0"
  } else if (linkType == 'coupon'){//优惠券的 商品详情
    n = "/pages/product/detail/index?id=" + linkId + "&group_id=0&groupopenId=0"
  } else {
    var linkId = a.id
    n = "/pages/product/detail/index?id=" + linkId
  }
  // s = (e.saOption || {}).componentName;
  return n;//i && (n += "&activityId=" + i), s && (n += "&sa_unit=" + s),
}
//商品页
function goPage(e) {
  console.log('商品页 e', e)
  var a = e.data.item.linkUrl, t = e.data.item.linkTitle;
  return t && (a += "&title=" + t), a;
}

Object.defineProperty(exports, "__esModule", {
  value: !0
});

var s = require("../../../utils/formatTime.js");

exports.default = {
  goLink: e,
  getMultitypeUrl: t
}, exports.goLink = e, exports.getMultitypeUrl = t;